<include file="Public:center_header" />
	<div class="content">
		<include file="Public:center_left" />
		<div class="content_right">
			<table class="myAttention" width="100%" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<td style="width: 10%;" align="center">序号</td>
				        <td style="width: 20%;" align="center">企业名称</td>
				        <td style="width: 20%;" align="center">地址</td>
				        <td style="width: 20%;" align="center">关注</td>
					</tr>
				</thead>
				<tbody>
					<tr style="height: 30px;"></tr>
					<volist name="attention_result" id="vo">
				        <tr>
				            <td align="center" style="color:grey">{$vo.aid}</td>
				            <td align="center"><a href="javascript:void(0)" onclick="return_company(this)" a_href="{:url('company/company_info',array('company_id'=>$vo.id))}" style="display:block;color:grey">{$vo.name}</a></td>
				            <td align="center" style="color:grey">{$vo.path_tem}</td>
				            <if condition="$vo.is_attention eq 0 || $vo.is_attention eq -1">
					            <td align="center">
					            	<a href="javascript:void(0)" style="display:block;" class="btn1" onclick="change_class(this)" <if condition="$vo.is_attention eq -1">status="1"<else />status="0"</if>company_id="{$vo.id}">
											+关注
									</a>
								</td>
							</if>
							<if condition="$vo.is_attention eq 1">
								<td align="center">
									<a href="javascript:void(0)" style="display:block;" class="btn3" onclick="change_class(this)" status="-1" company_id="{$vo.id}">
										取消关注
									</a>
								</td>
							</if>
				        </tr>
				    </volist>
					
				</tbody>
			</table>
			<div class="line"></div>
			<div class="page">
			    {$page}
			</div>
		</div>
	</div>
	<include file="Public:footer" />
	<script>
	    function project_submit(){
	        $('form').submit();
	    }

	    function change_class(obj){
	    	var status = $(obj).attr('status');
	    	var company_id = $(obj).attr('company_id');
	    	var class_name = $(obj).attr('class');
	    	var bool = false;

	    	var formData = new FormData();
	    	formData.append('status',status);
	        formData.append('company_id',company_id);

	    	$.ajax({
	            url:"{:url('Company/follow')}",
	            type:'POST',
	            data:formData,
	            async:false,
	            processData:false,
	            contentType:false,
	            success:function(result){
	            	if(result.code == 0){
	            		layer.alert(result.msg);
	            		bool = true;
	            	}
	            }

	        });

	        if(bool){
	        	return false;
	        }


	    	$(obj).removeClass('btn1');
	    	$(obj).removeClass('btn3');
	    	//$(obj).attr('status','');

	    	if(class_name == 'btn1'){
	    		$(obj).attr("class","btn3");
	    		$(obj).text("取消关注");
	    		$(obj).attr('status','-1');
	    	}else{
	    		$(obj).attr("class","btn1");
	    		$(obj).attr('status','1');
	    		$(obj).text("+关注");
	    	}
	    	
	    
		}

	    function return_company(obj){
	        var a_href = $(obj).attr('a_href');

	        $.ajax({
	            url:a_href,
	            type:'POST',
	            async:false,
	            processData:false,
	            contentType:false,
	            success:function(result){
	                if(result.code == 0){
	                    layer.alert(result.msg);
	                    return false;
	                }

	                location.href=a_href;
	            }

	        });
	    }
	</script>
</body>
</html>